<template>
	<view>
		<navigator url="../ajax/ajax" open-type="navigate"> 去登陆</navigator>
	</view>
</template>

<script>
	import {
		ref,
		toRefs,
		reactive
	} from 'vue';
	export default {
		setup() {

			uni.addInterceptor("navigateTo", {
				invoke(args) {
					console.log(args);
					if (args.url == "../ajax/ajax") {
						args.url = "../QA/QA";
						console.log(args.url);
					}
				}
			})

			uni.addInterceptor("request", {
				invoke(args) {

					let check = uni.getStorageSync("tokenid");
					console.log('invoke', check)
					if (!check) {
						uni.reLaunch({
							url: '/pages/ajax/ajax'
						})
					}
				},
				success() {
					console.log("success");
				}
			})

			uni.request({
				url: "https://8c0ca265-f640-4eda-a886-92bd742a95fa.bspapp.com/http/goods/goodsList",
				header: {
					token: uni.getStorageSync("tokenid")
				},
				success(res) {
					console.log(res)
					if (res.data.code == 3) {
						uni.showToast({
							title: res.data.msg,
							success() {
								uni.reLaunch({
									url: "/pages/ajax/ajax"
								})
							}
						})
					} else {
						console.log(res.data.data)
					}
				}
			})

		}
	}
</script>

<style scoped>

</style>
